class DiskStats
  @@disk_counter_names = %w{
    read_ios
    read_merges
    read_sectors
    read_msecs
    write_ios
    write_merges
    write_sectors
    write_msec
    in_flight
    svc_msec
    msec_in_queue
    }
  def initialize()
    @diskstats = Hash.new
    diskstats = IO.readlines("/proc/diskstats")
    diskstats.each do |line|
      fields = line.split(' '); fields.shift; fields.shift # drop major and minor number
      name = fields.shift
      next if name =~ /ram/
      next if name =~ /loop/
      if (fields.length >= 11)
        @@disk_counter_names.each do |counter_name|
          @diskstats["#{name}_#{counter_name}"] = fields.shift
        end
      end
    end
  end
end
